package com.dingqb.main.ui;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.dingqb.more.R;

public class WebViewActivity extends Activity {

	TextView mTextview;
	Button mBtn1;
	WebView mWebView;
	Context mContext;

	@SuppressLint({ "JavascriptInterface", "SetJavaScriptEnabled" })
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_webview);
		// 初始化
		initViews();

		// 设置编码
		mWebView.getSettings().setDefaultTextEncodingName("utf-8");
		// 支持js
		mWebView.getSettings().setJavaScriptEnabled(true);
		// 设置背景颜色 透明
		mWebView.setBackgroundColor(Color.argb(0, 0, 0, 0));
		// 设置本地调用对象及其接口
		mWebView.addJavascriptInterface(new JavaScriptObject(mContext), "myObj");
		// 载入js
		mWebView.loadUrl("file:///android_asset/test.html");
		// mWebView.loadUrl("file:///android_asset/text.html");

		// 点击调用js中方法
		mBtn1.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				mWebView.loadUrl("javascript:funFromjs()");
				Toast.makeText(mContext, "调用javascript:funFromjs()",
						Toast.LENGTH_LONG).show();
			}
		});

	}

	public void initViews() {

		mBtn1 = (Button) findViewById(R.id.btn_1);

		mTextview = (TextView) findViewById(R.id.tv_view);
		mWebView = (WebView) findViewById(R.id.wv_view);

		mContext = getApplicationContext();
	}
/**
 * 
 */
	void opengl() {
		GLSurfaceView ss = new GLSurfaceView(this);
		ss.animate();
		float orginal = 5490;
		float add = 500;
		float sum = orginal + add;
		float rewar = 8000;
		//
		float sum2016 = orginal + add + sum + rewar;
		int i = 13940;
		int j = 23060;
		int s = 37000;// (2016.3-2017.1)=11 37000 +11000=48w

	}

}
